import random
import math
import flask
from flask_cors import CORS
import random


app = flask.Flask(__name__)  # 创建服务器实例
CORS(app)  # 开启全局跨域
app.debug = True  # 开启调试模式，自动重载代码并显示调试信息


network_layers = 10  # 网络层数，取值：5到15
client_num = 4  # client数量，取值：1到5
# 每个client的层数的列表,取值：1到network_layers-1
client_layers_arr = [(1 + math.floor(random.random() * (network_layers-1)))  for x in range(client_num) ]  #这里取随机数作为测试

def change123(tmp):
    global network_layers
    network_layers = tmp


# 通过json传输数组数据
@app.route('/')
def get_data():
    print(network_layers)
    json_data = {
        "network_layers": network_layers,
        "client_num": client_num,
        "client_layers_arr": client_layers_arr
    }
    return json_data



if __name__ == '__main__':
    app.run(host="127.0.0.1", port=5000)